/**
 * @author Elísa og Ingvar
 * @version 1.0
 * @since 2/10/13
 */
public class Token {


    public enum TokenCode {INT, PLUS, MULT, LPAREN, RPAREN, ERROR, END}

    private String lexeme;
    private TokenCode tCode;

    public Token(){

    }

    public Token(String lexeme){
        this.lexeme  = lexeme;
    }

    public Token(String lexeme, TokenCode tokenCode){
        this.lexeme = lexeme;
        this.tCode = tokenCode;
    }

    public void setLexeme(String lexeme){
        this.lexeme = lexeme;
    }


    public String getLexeme() {
        return lexeme;
    }

    public void setTokeCode(TokenCode tokenCode){
        this.tCode = tokenCode;
    }

    public TokenCode getTokenCode(){
        return this.tCode;
    }

    public TokenCode getTokenCode(String string) {

        if (string.matches("[0-9]+")) {
            return TokenCode.INT;

        } else if (string.equals("+")) {
            return TokenCode.PLUS;

        } else if (string.equals("*")) {
            return TokenCode.MULT;

        } else if (string.equals("(")) {
            return TokenCode.LPAREN;

        } else if (string.equals(")")) {
            return TokenCode.RPAREN;

        } else if (string.equals("\n")) {
            return TokenCode.END;

        } else {
            return TokenCode.ERROR;

        }
    }

}
